package com.maud.util;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Log;

public class BitMapUtil {
	 
	private final static String ALBUM_PATH  
    = Environment.getExternalStorageDirectory() + "/hyjj_images/"; 
	public static Bitmap getBitmap(String url){
		Log.e("从sdcard加载图片", url);
		return BitmapFactory.decodeFile(url);
	}
	 

	 public static void saveFile(Bitmap bm, String fileName) throws IOException {  
	        File dirFile = new File(ALBUM_PATH);  
	        if(!dirFile.exists()){  
	            dirFile.mkdir();  
	        }  
	        File myCaptureFile = new File(ALBUM_PATH + fileName);  
	        Log.e("保存文件的路径为:", myCaptureFile.getAbsolutePath());
	        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));  
	        bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);  
	        bos.flush();  
	        bos.close();  
	    }  
}
